package com.cimu.freemarker.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Title: FreemarkerController
 * Copyright: Copyright (c) 2017
 *
 * @author cimu
 * date 2018年11月20日 19:02
 */
@Controller
public class FreemarkerController {

    @GetMapping("/freemarker")
    public ModelAndView index(ModelAndView modelAndView) {
        //你的freemarker文件名称
        modelAndView.setViewName("freemarker");
        modelAndView.addObject("data", "我是数据");
        List<String> strList = new ArrayList<>();
        strList.add("1");
        strList.add("2");
        modelAndView.addObject("list", strList);
        Map<String,String> map = new HashMap<>(2);
        map.put("name","张三");
        map.put("age","24");
        modelAndView.addObject("map", map);
        return modelAndView;
    }

}
